package com.yaoxun.bored.model.sys.menu;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;

import com.yaoxun.bored.common.BaseModel;

@Table(name="b_menu")
public class Menu extends BaseModel implements Serializable {

	private static final long serialVersionUID = -6471200446823888636L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="menu_id")
	private Integer menuId;
	
	@Column(name="menu_name")
	@NotEmpty(message="请输入名称")
	@Size(max=45, message="只允许输入{max}个以内字符")
	private String menuName;
	
	@Column(name="parent_id")
	@NotNull(message="上级菜单参数不合法")
	@Min(value=0, message="上级菜单参数不合法")
	private Integer parentId = 0;
	
	@Column(name="parent_name")
	@Size(max=45, message="只允许输入{max}个以内字符")
	private String parentName = "";
	
	private String path;
	
	@Column(name="menu_type")
	@Min(value=0, message="菜单类型参数不合法")
	private Integer menuType = 0;
	
	@Size(max=255, message="只允许输入{max}个以内字符")
	private String url = "";
	
	@Size(max=45, message="只允许输入{max}个以内字符")
	private String icon = "";
	
	private Integer leaf = 1; //是否是叶子，0--不是，1--是
	
	private Integer level = 1;
	
	private Float sort = 1F;

	public Integer getMenuId() {
		return menuId;
	}

	public void setMenuId(Integer menuId) {
		this.menuId = menuId;
	}

	public String getMenuName() {
		return menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	public Integer getParentId() {
		return parentId;
	}

	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		if(parentName != null) {			
			this.parentName = parentName;
		}
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public Integer getMenuType() {
		return menuType;
	}

	public void setMenuType(Integer menuType) {
		if(menuType != null) {			
			this.menuType = menuType;
		}
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		if(url != null) {			
			this.url = url;
		}
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		if(icon != null) {			
			this.icon = icon;
		}
	}

	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		if(level != null) {			
			this.level = level;
		}
	}

	public Float getSort() {
		return sort;
	}

	public void setSort(Float sort) {
		if(sort != null) {			
			this.sort = sort;
		}
	}

	@Override
	public String toString() {
		return "Menu [menuId=" + menuId + ", menuName=" + menuName + ", parentId=" + parentId + ", parentName="
				+ parentName + ", path=" + path + ", menuType=" + menuType + ", url=" + url + ", icon=" + icon
				+ ", level=" + level + ", sort=" + sort + ", toString()=" + super.toString() + "]";
	}

	public Integer getLeaf() {
		return leaf;
	}

	public void setLeaf(Integer leaf) {
		if(leaf != null) {			
			this.leaf = leaf;
		}
	}

}
